package progress.exa28_1.part5;

/**
 * 线程不安全的类
 */
public class UnSynAccount implements Runnable {

    private int money;

    private static int age;

    public void unSynDeposit(int i){
        money += i;
    }

    public static void unSynDeposit1(int i){
        age += i;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        unSynDeposit(5);
        unSynDeposit1(5);
    }

    @Override
    public String toString() {
        return "Account{" +
                "money=" + money +
                " age="+ age+
                '}';
    }

}
